﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class adm_vlg_yeuCauThanhToan : System.Web.UI.Page
{
    CommonPage cm3 = new CommonPage();
    VLGDataContext _db8 = new VLGDataContext();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            fillDulieuLenGrid();
            //if (cm3.IsAuthenticated == false)
            //{
            //    Response.Redirect(ResolveClientUrl("~/accessDenied.aspx"));
            //}
            //else
            //{
            //    fillDulieuLenGrid();
            //}
        }
    }
    void fillDulieuLenGrid()
    {
        //int idUs = cm3.Customer.idAcc;
        var list = from gg2 in _db8.YeuCauChuyenKhoans
                      orderby gg2.ngay descending
                      select gg2;   
        
        GridView1.DataSource = list;
        GridView1.DataBind();
    }
    protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {

        fillDulieuLenGrid();
        GridView1.PageIndex = e.NewPageIndex;
        GridView1.DataBind();
    }
     //Cập nhật ẩn hiện trên lưới
    public void chkAnHien_OnCheckedChanged(object sender, EventArgs e)
    {
        CheckBox chkAnHien = (CheckBox)sender;
        GridViewRow row = (GridViewRow)chkAnHien.NamingContainer;
        string cid = chkAnHien.ToolTip;
        bool status = chkAnHien.Checked;
        Category cate = _db8.Categories.SingleOrDefault(x => x.idCategory == int.Parse(cid));
        cate.AnHien = status;
        _db8.SubmitChanges();
        fillDulieuLenGrid();
    }
    protected void linkAdd_Click(object sender, EventArgs e)
    {
        Response.Redirect(ResolveClientUrl("~/qlcongviec.aspx?op=add"));
    }
    //protected void linkDelG_Click(object sender, EventArgs e)
    //{
    //    try
    //    {
    //        string lDel = ((LinkButton)sender).CommandArgument.ToString();
    //        Category giDel = _db8.Categories.Single(x => x.idCategory == int.Parse(lDel));
    //        _db8.Categories.DeleteOnSubmit(giDel);
    //        _db8.SubmitChanges();
    //        this.fillDulieuLenGrid();
    //    }
    //    catch
    //    {
    //        //this.fillDulieuLenGrid();
    //        //Literal1.Text = "<script type=\"text/javascript\">" +
    //        //                    "$(function() { " +
    //        //                    "alert(\"Không thể xóa danh mục đang sử dụng.\");" +
    //        //                    "});" +
    //        //                    "</script>";
    //    }
    //}
    protected void linkEditG_Click(object sender, EventArgs e)
    {

    }
}
